﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.APP.Application.Command.Breeding;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{
    /// <summary>
    /// Api 控制器-养殖管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingController : ControllerBase
    {
        private readonly IMediator mediator;

        public BreedingController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 养殖信息新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> GetAdd(BreedingAddCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 养殖信息显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Breeding_Information>>> ShowAll([FromQuery] ShowBreedingCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 修改养殖信息详情
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> GetUpdate(UpdateBreedingCommand command)
        { 
            return mediator.Send(command);
        }


    }
}
